# -*- coding: utf-8 -*-
"""
@Time: 2022/2/24 08:34
@Author: jins
@File: table_device.py
@Introduction: 
"""
from common.operateRedis import RedisHash
from common.mysqlDataOperate import OperateMysql
from common.operateRedis import RedisString

om = OperateMysql(version='dxy')
rh = RedisHash(version='dxy')
res = om.excute_sql("""select device_id ,device_code from device_center.device where short_name = 'short_name'""")
for item in res:
    name = 'DEVICE_CENTER:device:' + item[0]
    value = item[1]
    rh.insert_key_value(name, 'device_code', value)
    rh.insert_key_value(name, 'collect_frequence', 'mi15')
    rh.insert_key_value(name, 'sys_type', 'es')
    rh.insert_key_value(name, 'region_code', '1')

# rs = RedisString()
# for item in res:
#     name = 'DEVICE_CENTER:DEVICE_CODE:' + item[1]
#     value = item[0]
#     rs.insert(name, value)
